package com.qing.eduservice.controller;


import com.qing.eduservice.client.UcenterClient;
import com.qing.eduservice.service.StatisticsDailyService;
import com.qing.servicebase.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author Yjx
 * @since 2022-09-19
 */
@RestController
@RequestMapping("/staservice/daily")
@CrossOrigin
public class StatisticsDailyController {

    private final StatisticsDailyService service;

    public StatisticsDailyController(StatisticsDailyService service) {
        this.service = service;
    }

    @PostMapping("/{day}")
    public ResponseResult createStatisticsByDate(@PathVariable String day) {
        return service.createStatisticsByDay(day);
    }

    @GetMapping("/show-chart/{begin}/{end}/{type}")
    public ResponseResult showChart(@PathVariable String begin,@PathVariable String end,@PathVariable String type){
        Map<String, Object> map = service.getChartData(begin, end, type);
        return ResponseResult.ofSuccess(map);
    }


}

